/**
 *  chenjie
 *  2012-5-8
 *  
 */

package
{
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.ContextMenuEvent;
	import flash.external.ExternalInterface;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	import flash.system.Capabilities;
	import flash.system.Security;
	import flash.ui.ContextMenu;
	import flash.ui.ContextMenuItem;

	public class InitClass
	{
		public function InitClass(mvcAs3Player:MVCAs3Player)
		{
			mvcAs3Player.stage.scaleMode=StageScaleMode.NO_SCALE;
			mvcAs3Player.stage.align = StageAlign.TOP_LEFT;
			
			var cm:ContextMenu=new ContextMenu();
			cm.hideBuiltInItems();
			var con:ContextMenuItem = new ContextMenuItem("返回主页")
			cm.customItems.push(con);
			con.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,menuItemSelectHandler); 
			mvcAs3Player.contextMenu=cm;
			Security.allowDomain("*");
			Security.allowInsecureDomain("*");
			
			if(ExternalInterface.available) {
				ExternalInterface.addCallback("play", mvcAs3Player.receivedFromJavaScript);    
			}
		}
		
		private function menuItemSelectHandler(e:ContextMenuEvent):void
		{     
			if (Capabilities.playerType == 'ActiveX')
			{
				ExternalInterface.call("window.open","http://www.7227.com");
			}
			else
			{
				navigateToURL(new URLRequest("http://www.7227.com"),"_blank");
			}
		}  
		
	}
}